package cn.ichiva.tushare.analysis.data.国内宏观.利率数据;

import cn.ichiva.tushare.analysis.Config;
import cn.ichiva.tushare.sdk.tushare.TuClient;
import cn.ichiva.tushare.sdk.tushare.TuDataCacheAble;
import cn.ichiva.tushare.sdk.tushare.entity.TuRequest;

import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * HIBOR利率
 *
 * HIBOR (Hongkong InterBank Offered Rate)，是香港银行同行业拆借利率。
 * 指香港货币市场上，银行与银行之间的一年期以下的短期资金借贷利率，
 * 从伦敦同业拆借利率（LIBOR）变化出来的。
 *
 * 获取2000年到现在的所有数据
 */
public class Hibor extends TuDataCacheAble {

    public Hibor(TuClient client) {
        super(client);

        TuRequest request = new TuRequest();
        request.setApi("hibor");
        request.setDescribe("Hibor利率");

        HashMap<String,String> paramsMap = new HashMap<>();
        paramsMap.put("start_date","20000101");
        //paramsMap.put("end_date",DateUtils.lastTUDateString());
        request.setParams(paramsMap);

        LinkedHashMap<String,String> fieldMap = new LinkedHashMap<>();
        fieldMap.put("date","日期");
        fieldMap.put("on","隔夜");
        fieldMap.put("1w","1周");
        fieldMap.put("2w","2周");
        fieldMap.put("1m","1个月");
        fieldMap.put("2m","2个月");
        fieldMap.put("3m","3个月");
        fieldMap.put("6m","6个月");
        fieldMap.put("12m","12个月");

        request.setFieldMap(fieldMap);
        setRequest(request);
    }

    public static void main(String[] args) {
        new Hibor(new TuClient(Config.url, Config.token))
                .get().ifPresent(System.out::println);
    }
}
